package com.khoinguyen.feedtweet.dao;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.exceptions.PersistenceException;
import org.apache.ibatis.session.SqlSession;

import com.khoinguyen.feedtweet.model.VOTweet;

public class TweetDao extends Dao {
	public static void insertTweet(VOTweet tweet) {
		SqlSession session = sqlSessionFactory.openSession(true);
		try {
			session.insert("insertTweet", tweet);
		} catch (PersistenceException e) {
			e.printStackTrace();
		}
		session.close();
	}

	public static List<VOTweet> getTweetsByAuthorId(long authorId) {
		List<VOTweet> result = new ArrayList<VOTweet>();
		SqlSession session = sqlSessionFactory.openSession();
		result = session.selectList("getTweetsByAuthorId", authorId);
		session.close();
		return result;
	}
}
